package Basicas;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.tidy.Tidy;
import repositorio.RepositorioMegaSenaBD;

/**
 *
 * @author Hailton
 */
public class Dados {
    
    public static void main(String[] args) throws FileNotFoundException{
    Dados.TrataDados();
    }
    public static void TrataDados() throws FileNotFoundException{
        
        FileInputStream FIS = new FileInputStream("C:\\TutorialArquivos\\d_megasc.htm");
        Tidy T = new Tidy();
        Document doc = T.parseDOM(FIS,null);
        NodeList cds = doc.getElementsByTagName("tr");
        int size = cds.getLength();
        String[][] valores = new String[size][19];
        RepositorioMegaSenaBD mega = new RepositorioMegaSenaBD();
        int teste = 0;
        
        mega.deleteDados();

              for (int i = 0; i < size; i++) {
                   Element cd =  (Element) cds.item(i);
                   NodeList td = cd.getElementsByTagName("td");
                   int tam = td.getLength();
                        if(i > 0){
                            for (int j = 0; j < tam; j++) {
                                Element tds = (Element) td.item(j);
                                valores[i][j] = tds.getFirstChild().getNodeValue();
                            }
                        }
                }
              System.out.println("----->"+size);
              
              mega.inserirJogo(valores,size);
                System.out.println(mega.procuraNumero(5));
              
              
              
    }
}